package com.czxy.controller;

import com.czxy.pojo.News;
import com.czxy.pojo.group.BaseResult;
import com.czxy.pojo.group.ConditionResult;
import com.czxy.service.NewsService;
import com.czxy.vo.SearchRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 网站快报 Controller
 * @author Liuyunqin 17674029449@163.com
 * @date 2018/12/20 8:43
 */
@RestController
@RequestMapping
public class NewsController {

    @Autowired
    private NewsService newsService;


    /**
     * 查询所有网站快报
     * @return
     */
   /* public ResponseEntity<Object> findAllNews(){
        List<News> allNews = newsService.findAllNews();
        BaseResult baseResult = new BaseResult(0,"成功",allNews);
        return ResponseEntity.ok(baseResult);
    }*/


    /**
     * 条件查询所有的网站快报（分页 + 排序）
     * @param request
     * @return
     */
    @GetMapping("news")
    public ResponseEntity<Object> findNewsByCondition(SearchRequest request){
        ConditionResult newsByCondition = newsService.findNewsByCondition(request);
        return ResponseEntity.ok(newsByCondition);
    }
}
